<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h="http://www.w3.org/1999/xhtml">
	<!-- Process XHTML from page like http://fr.groups.yahoo.com/group/Explo4x4/messages/1?xm=1&m=e&l=1 -->
	<xsl:output indent="yes" method="xml" />
	<xsl:template match="/h:html/h:body/h:table[3]/h:tr/h:td[2]/h:table[4]/h:tr">
		<!-- match="/h:html/h:body/h:table[3]/h:tr/h:td[2]/h:table[4]/h:tr[3][h:td[3]/h:table]" -->
		<!--<position> <xsl:value-of select="position()" /> </position> -->
		<xsl:if test="h:td[3]/h:table">
			<xsl:variable name="pos-message" select="position() - 1" />
			<xsl:variable name="tr-prec" select="preceding-sibling::h:tr" />
			<xsl:variable name="tr-prec1" select="$tr-prec[last()]" />
			<xsl:variable name="td3" select="$tr-prec1/h:td[3]" />
			<xsl:variable name="td3_de"
				select="substring-after( substring-before($td3, 'Date:'), 'De:')" />
			<xsl:variable name="td3_date"
				select="substring-after( substring-before($td3, 'Sujet:'), 'Date:')" />
			<!-- exemple :/html/body/table[3]/tr/td[2]/table[4]/tr[3]/td[3]/table 
				h:tr/h:td/h:pre -->
			<xsl:text>
		</xsl:text>
			<message>
				<id>
					<xsl:value-of select="$tr-prec1/h:td[2]" />
				</id>
				<de>
					<xsl:value-of select="normalize-space($td3_de)" />
				</de>
				<date>
					<xsl:value-of select="normalize-space($td3_date)" />
				</date>
				<objet>
					<xsl:value-of select="$td3/h:a" />
				</objet>
				<xsl:text>
			</xsl:text>
				<content>
					<xsl:copy-of select="h:td[3]/h:table/h:tr/h:td/h:pre/node()" />
				</content>
			</message>
		</xsl:if>

	</xsl:template>

	<!-- Par défaut ne copie rien -->
	<xsl:template match="node()|@*">
		<xsl:apply-templates select="@*|node()" />
	</xsl:template>
</xsl:stylesheet>